package com.ucs.rest.resource;

import org.apache.log4j.Logger;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

import com.ucs.dao.CategoryDao;
import com.ucs.restlet.firstres.XStremUtil;

public class CategoriesResource extends ServerResource{
	private static final Logger log = Logger.getLogger(CategoriesResource.class);
	private CategoryDao categoryDao;
	
	@Get("xml")
    public Representation toXml(){
    	try {
			return new StringRepresentation(XStremUtil.toXML(getCategoryDao().getCategories()));
		} catch (Exception e) {
			log.error("Could not get users", e);   
			return null;
		}
    	
    }

	public void setCategoryDao(CategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}

	public CategoryDao getCategoryDao() {
		return categoryDao;
	}

}
